/**
 * 
 */
package org.vsg.stock.core.indicator.kline;

import java.util.List;

import org.vsg.stock.core.indicator.coordinate.CoordinateConfiguration;
import org.vsg.stock.core.indicator.coordinate.CoordinateFactory;
import org.vsg.stock.core.indicator.coordinate.DefaultCoordinate;
import org.vsg.stock.core.indicator.coordinate.FullKLineOPConverter;
import org.vsg.stock.core.indicator.coordinate.OriginalDataPoint;
import org.vsg.stock.core.indicator.coordinate.SimpleCoordinateConfigration;
import org.vsg.stock.core.indicator.coordinate.SimpleUnitDefinitionBuilder;
import org.vsg.stock.core.indicator.coordinate.UnitDefinitionBuilder;
import org.vsg.stock.core.kline.DailyKLineStock;

/**
 * @author Bill Vison
 *
 */
public class DefaultCoordinateBuilder extends CoordinateBuilder {
	
	/**
	 * init factory 
	 */
	private static CoordinateFactory cf = CoordinateFactory.getInstance();
	

	private String stockCode;

	/* (non-Javadoc)
	 * @see org.vsg.stock.core.indicator.kline.CoordinateBuilder#buildup()
	 */
	@Override
	void buildup() {
		CoordinateConfiguration config = preparedConfigration();
		
		coordinate = new DefaultCoordinate();

		coordinate.setConfiguration( config );
		coordinate.setStockCode(stockCode);
		
		coordinate.setOPConverter( new FullKLineOPConverter() );

		coordinate.setKlineListInThisCycle( dkStkList );
		//coordinate.setStkDateUtilExtension(utilExtension);
		coordinate.init();
	
	}
	
	public void setStockCode(String stockCode) {
		this.stockCode = stockCode;
	}
	
	private CoordinateConfiguration preparedConfigration() {
		SimpleCoordinateConfigration coordinateConfigration = new SimpleCoordinateConfigration();
		coordinateConfigration.setOriginPoint( this.originalDatePoint  );
		
		if ( this.definedBuilder == null) {
			coordinateConfigration.setUnitDefinitionBuilder( new SimpleUnitDefinitionBuilder() );
		} else {
			coordinateConfigration.setUnitDefinitionBuilder( this.definedBuilder );
		}
		
		
		return coordinateConfigration;
	}
	
	private List<DailyKLineStock>  dkStkList;

	/* (non-Javadoc)
	 * @see org.vsg.stock.core.indicator.kline.CoordinateBuilder#setDailyKLineStockList(java.util.List)
	 */
	@Override
	void setDailyKLineStockList(List<DailyKLineStock> importedList) {
		// TODO Auto-generated method stub
		dkStkList = importedList;
	}


	private OriginalDataPoint originalDatePoint;

	@Override
	void setOriginalDataPoint(OriginalDataPoint odp) {
		this.originalDatePoint = odp;		
	}

	private UnitDefinitionBuilder definedBuilder;

	@Override
	void setUnitDefinitionBuilder(UnitDefinitionBuilder customBuilder) {
		// TODO Auto-generated method stub
		definedBuilder = customBuilder;
	}


	private DefaultCoordinate coordinate;

	@Override
	DefaultCoordinate getCoordinate() {
		// TODO Auto-generated method stub
		return coordinate;
	}

	
	

}
